﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace wlm.wsx.src.wlm.Newwsx
{
    class OperatorCompare:OperatorBase
    {

        public override bool OnCalculate(int[] operands)
        {
            if (operands == null || operands.Length != 2)
                return false;

            bool bResult = false;

            switch (this.OperatorSymbol)
            {
                case "LT":
                    bResult = operands[0] < operands[1];
                    break;
                case "GT":
                    bResult = operands[0] > operands[1];
                    break;
                case "GE":
                    bResult = operands[0] >= operands[1];
                    break;
                case "LE":
                    bResult = operands[0] <= operands[1];
                    break;
                case "EQ":
                    bResult = operands[0] == operands[1];
                    break;
            }

            return bResult;
        }

        public override double OnCalculate(double[] operands)
        {
            if (operands == null || operands.Length != 2)
                return 0;

             return Convert.ToDouble(this.OnCalculate(new int[] { (int)operands[0], (int)operands[1] }));
        }
    }
}
